var ORBIT_STARTING_Y = 0;
var ORBIT_HEIGHT = 600;
var SATE_HEIGHT = 100;

var SATE_POINTS = 50;
var ATTEMPT_BONUS_POINTS = 100;

var numberOfSates;
var sateNumber;

function Game()
{
	this.score = 0;
	this.level = 1;
	this.attempts = 5;
	this.sateHeights = new Array();
	
}
//Reset function that resets all the values back to their original numbers.
Game.prototype.resetGame = function()
{
	this.score = 0;
	this.level = 1;
	this.attempts = 5;
	this.sateHeights = new Array();
}
//Playing field for the level that the user is currently on.
//Afterwards, the game will be drawn onto the canvas.
Game.prototype.setGameLevel = function()
{
	numberOfSates = this.getNumberOfSates();
	this.sateHeights = new Array( numberOfSates );
	
	this.setAttempts( this.getNumberOfAttempts() );
	
	var numberOfIntervals = Math.floor( ( ORBIT_HEIGHT - SATE_HEIGHT * 2 ) / SATE_HEIGHT );
	
	for( i = 0; i < numberOfSates; i = i + 1 )
		{
			var height = Math.floor( Math.random() * numberOfIntervals ) * SATE_HEIGHT + ORBIT_STARTING_Y + SATE_HEIGHT;
			this.sateHeights[ i ] = height;
		}
}
//Calculates the number of orbit lines and satellites available on the field at a certain level.
Game.prototype.getNumberOfSates = function ()
{
	//For the first level, there will be 1 satellite.
	if( this.level == 1 )
		{
			return 1;
		}
	//For the second level, there will be 2 satellite.
	else if( this.level == 2 )
		{
			return 2;
		}
	//For the third level, there will be 3 satellites.
	else if( this.level == 3)
		{
			return 3;
		}
	//For the fourth level, there will be 4 satellites.
	else if( this.level == 4 )
		{
			return 4;
		}
	//For the fifth and final level, there will be 5 satellites.
	else if( this.level == 5 )
		{
			return 5;
		}
	else
		{
			return 0;
		}
}
//Calculates the number of attempts to launch the climbers given for each level.
Game.prototype.getNumberOfAttempts = function()
{
	//For the first level, with only 1 climbers, there will be 3 attempts
	//for practice
	if( this.level == 1 )
		{
			return 3;
		}
	//For the second level, with 2 , there will be 4 attempts
	//to make it a bit more challenging.
	if( this.level == 2 )
		{
			return 4;
		}
	//For the third level, with 3 climbers, there will be 5 attempts
	//to make it more difficult.
	if( this.level == 3 )
		{
			return 5;
		}
	//For the fourth level, with 4 climbers, there will be 5 attempts
	//for more difficulty.
	if( this.level == 4 )
		{
			return 5;
		}
	//For the final level, with only 5 climbers, there will be only 6 attempts
	//because it is the final round to beat the game and it needs to be hard.
	if( this.level == 5 )
		{
			return 6;
		}
}
Game.prototype.checkGameStatus = function()
{
	//sateNumber = sateContainers.length - 1;
	
	if( this.attempts == 0 /*&& sateNumber >= 1*/ )
		{
			return drawLoserCanvas();
		}
	else 
		{
			if( this.level == 6 && sateNumber == 0 )
				{
					return drawWinnerCanvas();
				}
		}
}
//Return the score function
Game.prototype.getScore = function()
{
	return this.score;
}
//Sets the score function
Game.prototype.setScore = function( score )
{
	this.score = score;
}
//Return the level function
Game.prototype.getLevel = function()
{
	return this.level;
}
//Sets the level function
Game.prototype.setLevel = function( level )
{
	this.level = level;
}
//Return the number of attempts function
Game.prototype.getAttempts = function()
{
	return this.attempts;
}
//Sets the number of attempts function
Game.prototype.setAttempts = function( attempts )
{
	this.attempts = attempts;
}
//Return the satellites heights function
Game.prototype.getSateHeights = function()
{
	return this.sateHeights;
}